package com.qxsx.midi.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.RelativeLayout;

import com.qxsx.midi.R;
import com.qxsx.midi.activity.exam.ApplyActivity;
import com.qxsx.midi.activity.exam.ClassVideoListActivity;
import com.qxsx.midi.activity.exam.ExamHandBookActivity;
import com.qxsx.midi.activity.exam.ExamProcessActivity;
import com.qxsx.midi.activity.exam.MidiTeacherActivity;
import com.qxsx.midi.activity.home.CertificateSearchActivity;
import com.qxsx.midi.activity.me.LoginActivity;
import com.qxsx.midi.config.AppContext;
import com.qxsx.midi.model.ExamCate;
import com.qxsx.midi.utils.SPUtils;

import java.util.ArrayList;

/**
 * Created by Joney on 2015/8/31.
 */
public class ExamFragment extends Fragment implements View.OnClickListener {
    private RelativeLayout rl_1, rl_2, rl_3, rl_4, rl_5, rl_6;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    String login_name;//用户名

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_exam, container, false);

        findById(v);

        return v;
    }

    @Override
    public void onResume() {
        super.onResume();
        login_name = (String) SPUtils.get(AppContext.getContext(), "login_name", "");

    }

    private void findById(View v) {
        rl_1 = (RelativeLayout) v.findViewById(R.id.rl_1);
        rl_2 = (RelativeLayout) v.findViewById(R.id.rl_2);
        rl_3 = (RelativeLayout) v.findViewById(R.id.rl_3);
        rl_4 = (RelativeLayout) v.findViewById(R.id.rl_4);
        rl_5 = (RelativeLayout) v.findViewById(R.id.rl_5);
        rl_6 = (RelativeLayout) v.findViewById(R.id.rl_6);


        rl_1.setOnClickListener(this);
        rl_2.setOnClickListener(this);
        rl_3.setOnClickListener(this);
        rl_4.setOnClickListener(this);
        rl_5.setOnClickListener(this);
        rl_6.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rl_1:
                if (login_name != "") {
                    startActivity(new Intent(AppContext.getContext(), ApplyActivity.class));
                } else {
                    startActivity(new Intent(getActivity(), LoginActivity.class));
                }
                break;
            case R.id.rl_2:
                startActivity(new Intent(AppContext.getContext(), ExamProcessActivity.class));
                break;
            case R.id.rl_3:
                startActivity(new Intent(AppContext.getContext(), ClassVideoListActivity.class));
                break;
            case R.id.rl_4:
                startActivity(new Intent(AppContext.getContext(), ExamHandBookActivity.class));
                break;
            case R.id.rl_5:
                startActivity(new Intent(AppContext.getContext(), CertificateSearchActivity.class));
                break;
            case R.id.rl_6:
                startActivity(new Intent(AppContext.getContext(), MidiTeacherActivity.class));
                break;


        }
    }
}
